
import 'package:flutter/material.dart';
import 'package:flutter_app/class/MyApp7.dart';

class MyApp8 extends StatelessWidget {
  const MyApp8({super.key});

   @override
   Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: 'Flutter 动画',
      theme: ThemeData(
        primarySwatch: Colors.deepPurple
      ),
      home: const MyFadeTest(title: 'Fade Demo'),
    );
  }
}


class MyFadeTest extends StatefulWidget {
    const MyFadeTest({super.key,this.title});

    final String? title;

    @override
    State<MyFadeTest> createState() => _MyFadeTest();
}


class _MyFadeTest extends State<MyFadeTest> with TickerProviderStateMixin {
     late AnimationController controller;
     late CurvedAnimation curve;

     @override
     void initState() {
       super.initState();
       controller = AnimationController(duration: const Duration(milliseconds: 2000), vsync: this);
       curve = CurvedAnimation(parent: controller, curve: Curves.easeIn);
     }
     
     @override
     Widget build(BuildContext context) {
     // TODO: implement build
     return Scaffold(
       appBar: AppBar(
         title: Text(widget.title ?? "Title"),
         actions: [
           IconButton(icon: const Icon(Icons.arrow_right),
               onPressed: (){
                   Navigator.push(context, MaterialPageRoute(builder: (context) => const MyApp7()));
               })
         ],
       ),
       body: Center(
         child: FadeTransition(
           opacity: curve,
           child: const FlutterLogo(
             size: 100.0,
           ),
         ),
       ),
       floatingActionButton: FloatingActionButton(
         tooltip: 'Fade',
         child: const Icon(Icons.brush),
         onPressed: (){
           controller.forward();
         },
       ),
     );
    }

    @override
    void dispose() {
      // TODO: implement dispose
      controller.dispose();
      curve.dispose();
      super.dispose();
    }
}